﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace KPIS.GERP.SERVICE.WorkflowService.Class
{
    public class Common
    {
        public static string ApprovedStatus = "A";
        public static string UsedStatus = "U";
        public static string WaitStatus = "W";
        /// <summary>
        /// ทำการส่งรายการไปอนุมัติแล้ว
        /// </summary>
        public static string ProcessStatus = "P";
        public static string DeletedStatus = "D";
        public static string CancelStatus = "C";

        public Nullable<int> ConvertToNullableInt(object objValue)
        {
            Nullable<int> intResult = null;
            int nResult;

            if (objValue != null && int.TryParse(objValue.ToString(), out nResult))
            {
                intResult = nResult;
            }

            return intResult;
        }

        public Nullable<double> ConvertToNullableDouble(object objValue)
        {
            Nullable<double> dblResult = null;
            double dResult;

            if (objValue != null && double.TryParse(objValue.ToString(), out dResult))
            {
                dblResult = dResult;
            }

            return dblResult;
        }

        public Nullable<DateTime> ConvertToNullableDateTime(object objValue)
        {
            Nullable<DateTime> dtmResult = null;
            DateTime dtResult;

            if (objValue != null && DateTime.TryParse(objValue.ToString(), out dtResult))
            {
                dtmResult = dtResult;
            }

            return dtmResult;
        }
    }
}